<template>
  <div class="page-container" :class="{'bg-grey':isIframe}">
    <div class="msg"
      v-loading="true"
      element-loading-spinner="el-icon-loading">
    </div>
  </div>
</template>

<script type="text/javascript">
import { mapGetters } from 'vuex'
export default {
  name: 'PartyLoginCb',
  computed: {
    // 操作类型 1登录 2绑定
    handleType () {
      return /bind/i.test(this.type) ? 2 : 1
    },
    isIframe () {
      return window.frames.length !== parent.frames.length
    },
    ...mapGetters(['appInfo'])
  },
  created () {
    /**
      {
        "type": "WxLoginFinish",
        "code": "0416Ed100tn31N18n40004JfIQ16Ed1g", 微信返回
        "state": "qekjdsbkje893214wechat" 微信返回原值
      }
     */
    const query = this.$route.query
    this.type = query.type
    this.authCode = query.code
    const arr = ['google', 'facebook']
    if (query.order_id) return
    if (arr.includes(this.type)) {
      this.$router.replace({
        path: '/third-login',
        query: this.$route.query
      })
    } else if (query.sign) {
      this.$xzAsy('xz_CloseWnd')
    } else if (this.handleType === 1) {
      window.parent.onWxLoginFinish && window.parent.onWxLoginFinish({ code: this.authCode })
    } else {
      window.parent.onBindWxLoginFinish && window.parent.onBindWxLoginFinish({ code: this.authCode })
    }
  }
}
</script>

<style lang="scss" scoped>
.page-container.bg-grey{
  display: block;
  width: 100%;
  margin-top: 0;
  background: #494a4f;
}
.msg {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 14px;
  vertical-align: middle;
  height: 100vh;
  text-align: center;
  /deep/.el-loading-spinner {
    margin-top: -10px;
    i {
      font-size: 18px;
    }
  }
  /deep/.el-loading-mask {
    background: #494a4f;
  }
}
</style>
